package com.yangoxix.lovegoing.controller;

import com.yangoxix.lovegoing.service.ImageService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * The type Image controller.
 */
@Controller
@RequestMapping("image")
@Api(tags="图片管理接口")
public class ImageController {

    @Autowired
    private ImageService service;
    /**
     * The Spath.
     */
    static String Spath="";

    /**
     * Upload audio.
     *
     * @param file         the file
     * @param activityName the activity name
     */
    @PostMapping("uploadAudio")
    @ResponseBody
    public void uploadAudio(@RequestParam("upload") MultipartFile file,String activityName) {

//            保存图片
                String url = service.saveImag(file);
                System.out.println(url);
                service.SaveAuditImage(activityName,url);

    }

}
